/*
 * @(#)XfdmFuzzyCN2Complex.java        1.0 2000/05/09
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

package xfuzzy.xfdm.model.algorithm;

import xfuzzy.lang.*;

import java.util.ArrayList;

/**
 * Clase que describe un complejo (conjuncion de selectores) para el algoritmo FuzzyCN2
 * 
 * @author Pablo Mart�n Mu�oz
 *
 */
public class XfdmFuzzyCN2Complex {
	
	//----------------------------------------------------------------------------//
	//                            MIEMBROS PRIVADOS                               //
	//----------------------------------------------------------------------------//
	
	/**
	 * Lista de selectores del complejo
	 */
	public ArrayList<XfdmFuzzyCN2Selector> selectores;
	
	/**
	 * Conjunto global de operadores 
	 */
	private Operatorset opSet;
	
	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//

	/**
	 * Constructor basado en un conjunto de patrones "crisp"
	 */
	public XfdmFuzzyCN2Complex(Operatorset opSet) {
		selectores = new ArrayList<XfdmFuzzyCN2Selector>();
		this.opSet = opSet;
	}

	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//
	
	/**
	 * M�todo que computa el complejo para un patr�n
	 */
	public double compute(double[] input) {
		double val = this.selectores.get(0).compute(input);
		for(int i=0;i<this.selectores.size();i++) {
			double r = this.selectores.get(i).compute(input);
			val = this.opSet.and.compute(val,r);
		}
		return val;
	}
	
	/**
	 * Obtiene el conjunto de operadores
	 */
	public Operatorset getOpSet() {
		return opSet;
	}

	/**
	 * Asigna el conjunto de operadores 
	 */
	public void setOpSet(Operatorset opSet) {
		this.opSet = opSet;
	}

}
